Cytosim  PI
Cytoskeleton Simulator
Vector3 Class Reference

Detailed Description

We assume that the coordinates XX, YY and ZZ are adjacent in memory, which allows us to define an automatic conversion to a C-array. This is not guaranteed by the C-standard, but it usually works though...

Public Member Functions

 Vector3 ()
 by default, coordinates are not initialized
 
 Vector3 (const real x, const real y, const real z)
 construct from values
 
 Vector3 (const real v[])
 construct from address
 
 Vector3 (const real v[], const int &d)
 construct from array of size d
 
 ~Vector3 ()
 destructor (is not-virtual: do not derive from this class)
 
 operator real * ()
 implicit conversion to a modifiable real[] array
 
 operator const real * () const
 implicit conversion to a const real[] array
 
realaddr ()
 conversion to a 'real array'
 
realoperator[] (const unsigned ii)
 modifiable access to individual coordinates
 
void get (const real b[])
 replace coordinates by the ones provided
 
void get (const real v[], const int &d)
 copy coordinates from array of size d
 
void put (real b[]) const
 copy coordinates to given array
 
void addTo (real b[]) const
 add to given array
 
void addFrom (real b[])
 change coordinates by adding given array
 
void subTo (real b[]) const
 subtract to given array
 
void subFrom (real b[])
 change coordinates by subtracting given array
 
void set (const real x, const real y, const real z)
 change coordinates
 
void oppose ()
 change signs of all coordinates
 
real normSqr () const
 the square of the standard norm
 
real norm () const
 the standard norm = sqrt(x^2+y^2+z^2)
 
real normXY () const
 the 2D norm = sqrt(x^2+y^2)
 
real normXZ () const
 the 2D norm = sqrt(x^2+z^2)
 
real normYZ () const
 the 2D norm = sqrt(y^2+z^2)
 
real distanceSqr (Vector3 const &a) const
 square of the distance to other point == (a-this).normSqr()
 
real distance (Vector3 const &a) const
 distance to other point == (a-this).norm()
 
real minimum () const
 returns min(x, y, z)
 
real maximum () const
 returns max(x, y, z)
 
real norm_inf () const
 the infinite norm = max(|x|, |y|, |z|)
 
void normalize (const real n=1.0)
 normalize to norm=n
 
const Vector3 normalized (const real n=1.0) const
 returns the colinear vector of norm=n
 
const Vector3 orthogonal () const
 returns a perpendicular vector, of comparable but unspecified norm
 
const Vector3 orthogonal (const real n) const
 returns a perpendicular vector, of norm n
 
void getEulerAngles (real angles[]) const
 get the Euler angles
 
void setFromEulerAngles (const real angles[])
 set from Euler angles
 
const Vector3 e_mul (const real b[]) const
 returns the element-by-element product
 
const Vector3 e_div (const real b[]) const
 returns the element-by-element division
 
void operator+= (Vector3 const &b)
 addition of another vector b
 
void operator-= (Vector3 const &b)
 subtraction of another vector b
 
void operator*= (const real b)
 multiplication by a scalar
 
void operator/= (const real b)
 division by a scalar
 
std::string str () const
 conversion to a string
 
void print (FILE *out=stdout) const
 print to a file
 
void pprint (FILE *out=stdout) const
 print to a file, surrounded by parenthesis
 
void println (FILE *out=stdout) const
 print, followed by a new line
 
void addRand (real s)
 add a random component in [-s, s] to each coordinate
 
const Vector3 randPerp (real n) const
 a vector of norm n, orthogonal to *this, chosen randomly and uniformly
 

Static Public Member Functions

static unsigned dimensionality ()
 dimensionality
 
static Vector3 make (const real b[])
 create new Vector with coordinates from the given array
 
static const Vector3 randBox ()
 random Vector with coordinates set randomly and independently in [-1,+1]
 
static const Vector3 randBox (real n)
 set all coordinates randomly and independently in [-n,+n]
 
static const Vector3 randUnit ()
 random Vector of norm = 1; sampling is uniform More...
 
static const Vector3 randUnit (real n)
 return a random vector of norm = n; sampling is uniform More...
 
static const Vector3 randBall ()
 return a random vector of norm <= 1; sampling is uniform
 
static const Vector3 randBall (real n)
 return a random vector of norm <= n; sampling is uniform
 
static const Vector3 randGauss (real n)
 return a random vector with Normally distributed coordinates ~ N(0,n)
 

Public Attributes

real XX
 coordinates are public
 
real YY
 
real ZZ
 

Friends

const Vector3 operator+ (Vector3 const &a, Vector3 const &b)
 addition of two vectors
 
const Vector3 operator- (Vector3 const &a, Vector3 const &b)
 subtraction of two vectors
 
const Vector3 operator+ (Vector3 const &b)
 unary + operator does nothing
 
const Vector3 operator- (Vector3 const &b)
 opposition of a vector
 
const Vector3 vecProd (Vector3 const &a, Vector3 const &b)
 cross product of two vectors
 
real operator* (Vector3 const &a, Vector3 const &b)
 scalar product of two vectors
 
const Vector3 operator* (Vector3 const &a, const real s)
 multiplication by scalar s
 
const Vector3 operator* (const real s, Vector3 const &a)
 mutiplication by scalar s
 
const Vector3 operator/ (Vector3 const &a, const real s)
 division by scalar s
 
bool operator== (Vector3 const &a, Vector3 const &b)
 equality test
 
bool operator!= (Vector3 const &a, Vector3 const &b)
 non-equality test
 

Member Function Documentation

const Vector3 randUnit ( )
static

hypercube rejection method

const Vector3 randUnit ( real  n)
static

hypercube rejection method